import { createSlice, PayloadAction } from "@reduxjs/toolkit"
import { Tag } from "../Types/Api/tagType"

type State = {
  typeList: Tag[]
  issueType: string
}

export const typeSlice = createSlice({
  name: "type",
  initialState: {
    typeList: [],
    issueType: "all",
  } as State,
  reducers: {
    changeTypeList(state, action: PayloadAction<Tag[]>) {
      state.typeList = action.payload
    },
    changeIssueType(state, action) {
      state.issueType = action.payload
    },
  },
})

export const { changeTypeList, changeIssueType } = typeSlice.actions

export const typeReducer = typeSlice.reducer
